/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "password_recovery", catalog = "facetoframe", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PasswordRecovery.findAll", query = "SELECT p FROM PasswordRecovery p"),
    @NamedQuery(name = "PasswordRecovery.findByIdPasswordRecovery", query = "SELECT p FROM PasswordRecovery p WHERE p.idPasswordRecovery = :idPasswordRecovery"),
    @NamedQuery(name = "PasswordRecovery.findByToken", query = "SELECT p FROM PasswordRecovery p WHERE p.token = :token"),
    @NamedQuery(name = "PasswordRecovery.findByExpeditonDate", query = "SELECT p FROM PasswordRecovery p WHERE p.expeditonDate = :expeditonDate"),
    @NamedQuery(name = "PasswordRecovery.findByLimitDate", query = "SELECT p FROM PasswordRecovery p WHERE p.limitDate = :limitDate")})
public class PasswordRecovery implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "VALID")
    private boolean valid;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_PASSWORD_RECOVERY")
    private Integer idPasswordRecovery;
    @Size(max = 5)
    @Column(name = "TOKEN")
    private String token;
    @Basic(optional = false)
    @NotNull
    @Column(name = "EXPEDITON_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date expeditonDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "LIMIT_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date limitDate;
    @JoinColumn(name = "USER", referencedColumnName = "ID_USER")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private User user;

    public PasswordRecovery() {
    }

    public PasswordRecovery(Integer idPasswordRecovery) {
        this.idPasswordRecovery = idPasswordRecovery;
    }

    public PasswordRecovery(Integer idPasswordRecovery, Date expeditonDate, Date limitDate) {
        this.idPasswordRecovery = idPasswordRecovery;
        this.expeditonDate = expeditonDate;
        this.limitDate = limitDate;
    }

    public Integer getIdPasswordRecovery() {
        return idPasswordRecovery;
    }

    public void setIdPasswordRecovery(Integer idPasswordRecovery) {
        this.idPasswordRecovery = idPasswordRecovery;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Date getExpeditonDate() {
        return expeditonDate;
    }

    public void setExpeditonDate(Date expeditonDate) {
        this.expeditonDate = expeditonDate;
    }

    public Date getLimitDate() {
        return limitDate;
    }

    public void setLimitDate(Date limitDate) {
        this.limitDate = limitDate;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPasswordRecovery != null ? idPasswordRecovery.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PasswordRecovery)) {
            return false;
        }
        PasswordRecovery other = (PasswordRecovery) object;
        if ((this.idPasswordRecovery == null && other.idPasswordRecovery != null) || (this.idPasswordRecovery != null && !this.idPasswordRecovery.equals(other.idPasswordRecovery))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.PasswordRecovery[ idPasswordRecovery=" + idPasswordRecovery + " ]";
    }

    public boolean getValid() {
        return valid;
    }

    public void setValid(boolean valid) {
        this.valid = valid;
    }
    
}
